<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="/WEB-INF/jstl/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/jstl/fn.tld" prefix="fn" %>
<%@ taglib uri="/WEB-INF/jstl/fmt.tld" prefix="fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<html lang="zh-CN">
  <head>
   <base href="<%=basePath%>">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>商品管理页面</title>
	
	<link rel="stylesheet" type="text/css" href="<%=basePath%>assets/bootstrap/css/resetPro.css">
	<link href="<%=basePath%>assets/bootstrap/css/bootstrap-combined.min.css" rel="stylesheet">
	<script type="text/javascript" src="<%=basePath%>assets/bootstrap/js/jquery-2.0.0.min.js"></script>
	<script type="text/javascript" src="<%=basePath%>assets/bootstrap/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="<%=basePath%>assets/bootstrap/js/jquery-ui.js"></script>
	<script type="text/javascript" src="<%=basePath%>assets/bootstrap/js/jquery.ui.touch-punch.min.js"></script>
	<script type="text/javascript" src="<%=basePath%>assets/bootstrap/js/jquery.htmlClean.js"></script>
	<script type="text/javascript" src="<%=basePath%>assets/bootstrap/ckeditor/ckeditor.js"></script>
	<script type="text/javascript" src="<%=basePath%>assets/bootstrap/ckeditor/config.js"></script>
	<link rel="stylesheet" type="text/css" href="<%=basePath%>assets/bootstrap/Font-Awesome-3.2.1/css/font-awesome.min.css">
    <link rel="stylesheet" href="<%=basePath%>assets/onedate/css/BeatPicker.min.css"/>
    <script src="<%=basePath%>assets/onedate/js/BeatPicker.min.js"></script>
    <script src="<%=basePath%>assets/onedate/documents/js/prism.js"></script>
	
	
	<style type="text/css">
		a:hover{
			text-decoration: none!important;
		}
		.pzSpanClass{
		 	margin: 0 15px;
		}
		.pzClass{
			width:55px;
			height:25px;
		}
		.cheSpan{
				display: inline-block!important;
				min-width: 25px;
			}
		.keyinput{
			margin-bottom: 0px!important;
			height: 30px!important;
		}
		.datatable th, .datatable td{
		text-align:center!important;
		vertical-align:middle!important;
		}
		.foottable{
			border-top-width:0px!important;
			margin-top: -21px!important;
		}
		 .oneinput{
			margin-bottom: 0px!important;
			height: 30px!important;
		} 
		.onediv{
			width: 320px;
			margin: 0px auto;
			margin-top:22px;
			}
	    .inoneline{
	   		 display:inline-block!important;
			}
		.topZero{
			top: 0%!important;
		}
		.width130{
			width: 130px!important;
			margin: 0px auto;
		}
		
	</style>
  </head>
<body>
		<!-- 页面导航 -->
			<%@include file="../shared/pageTitle.jsp"%>
			<div class="row-fluid">
				<div class="span12">
				<!-- 页面信息 -->
		   		 <%@include file="../shared/info.jsp"%>
		    		<!-- 简单查询 -->
					 <form class=" text-right" action="<%=basePath%>goods/show" method="get">
						<input type="text" name="keys" class="keyinput" value="${keys}" placeholder="查询关键字"  >
								<button class="btn  btn-primary  " type="submit">
										<span class="icon-search  cheSpan"></span>查询</button>
							<a id="modal-330177" href="#modal-container-330177" role="button" class="btn btn-success" data-toggle="modal">
								<span class="icon-plus  cheSpan"></span>上架商品</a>
					</form>
					
					<div id="modal-container-330177" class="modal hide fade topZero" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
						<div class="modal-header">
							 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
							<h3 id="myModalLabel" class="text-info ">
								<span class="icon-user  cheSpan"></span>上架商品
							</h3>
						</div>
						<!--引入form-->
						<%@include file="addGoods.jsp"%>
					</div>
				</div>
			</div>
			<div class="row-fluid">
					<div class="span12">
							<table class="table table-bordered datatable">
								<thead style="background:#F5F5F5" >
									<tr>
										<th>
											商品ID
										</th>
										<th>
											商品名
										</th>
										<th>
											图片
										</th>
										<th>
											 单价(￥)
										</th>
										<th>
											上架日期
										</th>
										<!-- <th>类型</th> -->
										<th>
											库存
										</th>
										<th>
											状态<!-- 0 下架，1 在售 2 停产-->
										</th>
										<th>
											编辑
										</th>
									</tr>
								</thead>
							<c:choose>
					  		<c:when test="${(empty goodsPageInfo.basePageList) or (fn:length(goodsPageInfo.basePageList)<1)}">
						  		<h4 class="text-center text-error">
									所查商品信息为空
								</h4>
							</c:when>
							<c:otherwise>
		 					
								<tbody>
								<% 
								int i=0; 
								%>
								<c:forEach items="${goodsPageInfo.basePageList}" var="goods">
								
								<% i++;%>
									<tr class="<% if(i%2!=0){%>warning<%}else{%>info<%}%>">
										<td>
											${goods.id}
										</td>
										<td>
											${goods.name}
										</td>
										<td>
											<div class="width130">
												<c:choose>
										  		<c:when test="${empty goods.img}">
										  			<img src="<%=basePath%>assets/goodsimg/404.ico"  alt="${goods.img}" width="50px" alt="封面不存在"/>
												</c:when>
												<c:otherwise>
													<img src="<%=basePath%>assets/goodsimg/${goods.img}"  alt="${goods.img}" width="120px"/>
												</c:otherwise>
												</c:choose>
											</div>
										</td>
										
										<td>
											${goods.price}
										</td>
										<td>
											<fmt:formatDate pattern="yyyy-MM-dd" value="${goods.shelveDate}" />
										</td>
										<%-- <td>
											${goods.type}
										</td> --%>
										<td>
											${goods.num}
										</td>
										<td>
											${goods.state eq 1 ? "在售" : (goods.state eq 0 ?"下架" :"停产" )}<!-- 0下架，1在售-->
										</td>
										<td>
											<button type="button"  class="btn btn-success btn-block" 
												onclick="javascript:window.location.href='<%=basePath%>goods/edit/${goods.id}?oper=oneGoods';">
											<span class="icon-eye-open cheSpan"></span>详细</button>
											<button type="button"  class="btn btn-info btn-block" 
												onclick="javascript:window.location.href='<%=basePath%>goods/edit/${goods.id}?oper=editGoods';">
											<span class="icon-edit cheSpan"></span>信息修改</button>
											<button type="button"  class="btn btn-info btn-block" 
												onclick="javascript:window.location.href='<%=basePath%>goods/edit/${goods.id}?oper=editIMG';">
											<span class="icon-edit cheSpan"></span>图片修改</button>
										</td>
									</tr>
								</c:forEach>	
								</tbody>
							</table>
	    					
							<table class="table foottable" >
							<tbody>
								<tr >
								<td >
								<div class="uldiv pagination pagination-left ">
										<span class="label badge-info">记录总数:</span><span class="label badge-info">${goodsPageInfo.rootListSize}</span>
											<span class="label badge-success">页面大小:</span>
											<span >
												<select name="pageSize"  class="pzClass label badge-success"id="pzSelect" onchange="javascript:window.location.href='<%=basePath%>goods/show?pageSize='+$('#pzSelect').val()+'&nowPage=${goodsPageInfo.nowPage-1}&keys=${keys}';">
												<!-- 循环取出页面大小 -->
														<c:forEach items="${goodsPageInfo.pageSizeList}" var="pz">
															<option value="${pz}" <c:if test="${pz eq goodsPageInfo.pageSize}">selected="selected"</c:if> >${pz }</option>
														</c:forEach>
												</select>
											</span>
											<span class="label badge-important">当前页:</span><span class="label badge-important">${goodsPageInfo.nowPage}</span>
								 </div>
								</td>
								<td >
									<div class="pagination pagination-right">
										<ul class="oneul">
											<li>
												<a href="<%=basePath%>goods/show?pageSize=${goodsPageInfo.pageSize}&nowPage=${goodsPageInfo.nowPage-1}&keys=${keys}">上一页</a>
											</li>
											<c:forEach items="${goodsPageInfo.pageNoList}" var="no">
											<c:choose>
											<c:when test="${no ne -1}">
												<li >
													<a href="<%=basePath%>goods/show?pageSize=${goodsPageInfo.pageSize}&nowPage=${no==0?1:no}&keys=${keys}">${no==0?'...':no}</a>
												</li>
											</c:when><c:otherwise></c:otherwise>
											</c:choose>
											</c:forEach>
											<li>
												<a href="<%=basePath%>goods/show?pageSize=${goodsPageInfo.pageSize}&pageCount=${goodsPageInfo.pageCount}&nowPage=${goodsPageInfo.nowPage+1}&keys=${keys}">下一页</a>
											</li>
										</ul>
									</div>
								</td>
								</tr>
							</tbody>
					</c:otherwise>
					</c:choose>
							</table>
					
					
				</div>
		</div>
</body>

</html>
